home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swaga_c.zip / COMM.SWG / 0007_Dialing.pas < prev    next >
Pascal/Delphi Source File  |  1993-05-28  |  4KB  |  108 lines

  1. {
  2.  GL> I am writing a simple dialer and would like to know how do
  3.  GL> I recieve the mode String like "BUSY" and "NO CARRIER" , I
  4.  GL> tried opening the Comport For reading but i just hung the
  5.  GL> Computer. Could you please tell me how ?
  6.  GL> Regards , Gareth
  7.  
  8.   Gareth,
  9.   I didn't see any replies to your message, but I've been looking
  10.   For the same inFormation myself.  I saw the following code, based
  11.   on a message from Norbert Igl, last year.  When I dial my own
  12.   phone number, it gives me a busy signal For a second or two, and
  13.   then hangs up.  I don't know what makes the busy signal stop.  and
  14.   I don't know how to receive the modem String "BUSY" or "NO CARRIER"
  15.   or "NO DIALtoNE".
  16.  
  17.   I noticed in my modem manual that modem command X4 will
  18.   generate the following responses:
  19.  
  20.   Number Response       Word Response
  21.   (V0 command)           (V1 command)
  22.  
  23.      6                      NO DIALtoNE
  24.      7                      BUSY
  25.      8                      NO ANSWER
  26.                             (The modem responds With 8 if you send
  27.                             the @ command [Wait For Quiet Answer],
  28.                             and it didn't subsequently detect 5
  29.                             seconds of silence.)
  30.  
  31.      I wish I could figure out a way to "capture" the response, either the
  32.      number (say, 7) or the Word ('BUSY').  if I could detect a busy
  33.      signal, I could then create a loop that would make the
  34.      Program continually redial if it detected busy signals.
  35.  
  36.      if you figure it out, could you post your solution?
  37.  
  38.      Here's how Norbert's code With a few modifications:
  39.  
  40.  Date: 29 Jun 92  23:15:00
  41.  From: Norbert Igl
  42.  to:   Jud Mccranie
  43.  Subj: Dialing the phone
  44.  
  45.    here's a COM3-able version...(:-)}
  46.  
  47.    Program Dialing;
  48.    Uses Crt;
  49.    (* no error checking... *)
  50.  
  51.    Var ch : Char;
  52.        num : String;
  53.  
  54.    Function Dial( Nb:String; ComPort:Byte ):Char;
  55.             Const  DialCmd = 'ATDT';
  56.                    OnHook  = 'ATH';
  57.                    CR      =  #13;
  58.                    Status  =  5;
  59.             Var    UserKey : Char;
  60.             PortAdr : Word;
  61.  
  62.             Procedure Com_Write( S: String );
  63.                       Var i:Byte;
  64.  
  65.                       Function OutputOk:Boolean;
  66.                           begin
  67.                           OutPutOk := ( Port[PortAdr+Status] and $20) > 0;
  68.                           end;
  69.  
  70.                       Procedure ComWriteCh( Var CH:Char);
  71.                           begin
  72.                           Repeat Until OutPutOk;
  73.                           Port[PortAdr] := Byte(CH);
  74.                           end;
  75.  
  76.                       begin
  77.                       For i := 1 to length(s) do ComWriteCh(S[i]);
  78.                       end;
  79.  
  80.             Procedure Com_Writeln( S : String );
  81.                       begin
  82.                       Com_Write( S + CR )
  83.                       end;
  84.  
  85.    { DIAL.Main }
  86.    begin
  87.    if (ComPort < 1) or ( ComPort > 4) then Exit;
  88.    PortAdr := MemW[$40:(ComPort-1)*2 ];
  89.    if PortAdr = 0 then Exit;
  90.    Repeat
  91.        Com_Writeln( OnHook );
  92.        Delay( 500 );
  93.        Com_Write  ( DialCmd );
  94.        Com_Writeln( Nb );
  95.        UserKey := ReadKey;
  96.        Until UserKey <> ' ';         { Hit [SPACE] to redial ! }
  97.    Com_Writeln( OnHook );        { switch the line to the handset ...}
  98.    Dial := UserKey;              { see what key the user pressed... }
  99.    end;
  100.  
  101.   begin
  102.     ClrScr;
  103.     Write ('Enter your own phone number:  ');
  104.     Readln(Num);
  105.     Writeln('Dialing now... Should get a busy signal.');
  106.     ch := dial(Num,2);
  107.   end.
  108.